package jonggyuni.basic;

import java.util.Scanner;

public class Ch04_05 {

	public static void main(String[] args) {
		
		int a, b;
		int oper;
	
		Add add = new Add();
		Sun sun = new Sun();
		Mul mul = new Mul();
		Div div = new Div();
	
		Scanner sc = new Scanner(System.in);
		
		System.out.print("두 정수와 연산자를 입력하시오.(1.덧셈 2.뺄셈 3.곱셈 4.나눗셈)>>");
		a = sc.nextInt();
		b = sc.nextInt();
		oper = sc.nextInt();
	
		if(oper==1){
			add.setValue(a, b);
			System.out.println(a+"+"+b+"="+add.calculate());
		}
		else if(oper==2){
			sun.setValue(a, b);
			System.out.println(a+"-"+b+"="+sun.calculate());
		}
		else if(oper==3){
			mul.setValue(a, b);
			System.out.println(a+"x"+b+"="+mul.calculate());
		}
		else if(oper==4){
			div.setValue(a, b);
			System.out.println(a+"/"+b+"="+div.calculate());
		}
		else
			System.out.println("잘못입력하셨습니다");	
		
		sc.close();
		
	}//main

}//class

class Add{
	int a,b;
	int result;
	void setValue(int a,int b){
		this.a = a;
		this.b = b;
	}
	
	int calculate(){
		result = a+b;
		return result;
	}
	
}

class Sun{
	int a,b;
	int result;
	void setValue(int a, int b){
		this.a = a;
		this.b = b;
	}
	int calculate(){
		result = a-b;
		return result;
	}
}

class Mul{
	int a,b;
	int result;
	void setValue(int a, int b){
		this.a = a;
		this.b = b;
	}
	int calculate(){
		result = a*b;
		return result;
	}	
}

class Div{
	int a,b;
	int result;
	void setValue(int a, int b){
		this.a = a;
		this.b = b;
	}
	int calculate(){
		result = a/b;
		return result;
	}
}


/*class Add{// 덧셈 
	int result;
	public Add(){}
	public Add(int a,int b){
		result = a+b;
		System.out.println("합은 :" + result);
	}
}

class Sub{// 빼기
	int result;
	public Sub(){}
	public Sub(int a, int b){
		result = a-b;	
		System.out.println("차는 :" + result);
	}	
}

class Mul{// 곱하기
	int result;
	public Mul(){}
	public Mul(int a, int b){
		result = a*b;	
		System.out.println("곱은 :" + result);
	}	
}

class Div{// 나누기
	int result;
	public Div(){}
	public Div(int a, int b){
		result = a/b;
		System.out.println("몫은 :" + result);
	}
}*/
